# Install pre-commit hooks via `pip install pre-commit && pre-commit install`
default_stages:
  - pre-push
repos:
  - repo: https://github.com/doublify/pre-commit-rust
    rev: v1.0
    hooks:
    - id: clippy
      args: ['--manifest-path=client/Cargo.toml', '--all', '--']
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: "v0.1.0"
    hooks:
      - id: ruff
        args: [ --fix]
  - repo: https://github.com/psf/black
    rev: 23.10.0
    hooks:
      - id: black-jupyter
        exclude: ^(wandb/vendor/|wandb/proto/v.*/.*_pb2\.py|wandb/proto/v.*/.*_pb2_grpc\.py|wandb/proto/wandb_deprecated.py)
  - repo: https://github.com/asottile/blacken-docs
    rev: 1.16.0
    hooks:
      - id: blacken-docs
        exclude: ^(wandb/vendor/)
  - repo: https://github.com/pre-commit/mirrors-clang-format
    rev: v17.0.3
    hooks:
      - id: clang-format
        types_or: [proto]
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: check-merge-conflict
      - id: trailing-whitespace
        name: trailing-whitespace
        exclude: ^(wandb/|tests/|src/)
      - id: end-of-file-fixer
        name: end-of-file-fixer
        exclude: ^(wandb/|tests/|src/|.*_durations)
      - id: check-yaml
        name: check-yaml
        exclude: ^(wandb/|tests/)
      - id: check-added-large-files
        name: check-added-large-files
      - id: check-shebang-scripts-are-executable
        name: check-shebang-scripts-are-executable
        exclude: ^(wandb/|tests/)
      - id: check-executables-have-shebangs
        name: check-executables-have-shebangs
        exclude: ^(wandb/|tests/)
      - id: check-symlinks
        name: check-symlinks
      - id: check-toml
        name: check-toml
      - id: debug-statements
        name: debug-statements
        exclude: ^(wandb/__init__.py)
      - id: forbid-submodules
        name: forbid-submodules
  - repo: https://github.com/psf/black
    rev: 23.10.0
    hooks:
      - id: black
        files: '^core/'
  - repo: local
    hooks:
      - id: go-generate-proto
        name: 'go-generate-proto'
        entry: core/scripts/pre-commit-hooks/run-go-generate.sh
        files: '\.proto$'
        args:
          - ./api/proto
        pass_filenames: false
        language: 'script'
        description: "Runs `go generate`, requires golang"
      - id: go-generate-graphql
        name: 'go-generate-graphql'
        entry: core/scripts/pre-commit-hooks/run-go-generate.sh
        files: '\.graphql$'
        args:
          - ./api/graphql
        pass_filenames: false
        language: 'script'
        description: "Runs `go generate`, requires golang"
      - id: go-fmt
        name: 'go-fmt'
        entry: core/scripts/pre-commit-hooks/run-go-fmt.sh
        files: '\.go$'
        language: 'script'
        description: "Runs `gofmt`, requires golang"
      - id: go-imports
        name: 'go-imports'
        entry: core/scripts/pre-commit-hooks/run-go-imports.sh
        files: '\.go$'
        exclude: 'core/pkg/service/'
        language: 'script'
        description: "Runs `goimports`, requires golang"
      - id: go-unit-tests
        name: 'go-unit-tests'
        entry: core/scripts/pre-commit-hooks/run-go-unit-tests.sh
        files: '\.go$'
        language: 'script'
        description: "Runs `go test`"
        require_serial: true
      - id: go-vet
        name: 'go-vet'
        entry: core/scripts/pre-commit-hooks/run-go-vet.sh
        files: '\.go$'
        language: 'script'
        description: "Runs `go vet`, requires golang"
        require_serial: true
      - id: golangci-lint
        name: 'golangci-lint'
        entry: core/scripts/pre-commit-hooks/run-golangci-lint.sh
        types: [go]
        language: 'script'
        pass_filenames: false
      - id: go-critic
        name: 'go-critic'
        entry: core/scripts/pre-commit-hooks/run-go-critic.sh
        files: '\.go$'
        language: 'script'
        pass_filenames: false
        description: "Runs `go-critic`, requires https://github.com/go-critic/go-critic"
      - id: go-cyclo
        name: 'go-cyclo'
        entry: core/scripts/pre-commit-hooks/run-go-cyclo.sh
        files: '\.go$'
        exclude: 'core/pkg/service/'
        language: 'script'
        description: "Runs `gocyclo`, requires https://github.com/fzipp/gocyclo"
        args:
          - -over=21
      - id: go-mod-tidy
        name: 'go-mod-tidy'
        entry: core/scripts/pre-commit-hooks/run-go-mod-tidy.sh
        pass_filenames: false
        language: 'script'
        description: "Runs `go mod tidy -v`, requires golang"
      - id: go-build
        name: 'go-build'
        entry: core/scripts/pre-commit-hooks/run-go-build.sh
        files: '\.go$'
        language: 'script'
        description: "Runs `go build`, requires golang"
